package ru.elteam.web.beans.session;

import ru.elteam.logic.ListMessage;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Nikita.Brazhnikov
 */
@Named("comments_cache")
@SessionScoped
public class CommentsCacheBean implements Serializable{

	private Map<Long, List<ListMessage>> messages = new ConcurrentHashMap<Long, List<ListMessage>>(5);

	public List<ListMessage> getComments(Long objectId) {
		List<ListMessage> result = messages.get(objectId);
		if (result == null)
			return Collections.emptyList();
		return result;
	}
}
